<template>
  <view class="contain">
    <view>
      <u-toast ref="uToast" />
    </view>
    <view class="top-content"></view>

    <view class="top" >
      
    </view>
  <view class="box-contet"  v-for="(item, index) in groupNemberList" :key="index" style="padding:0rpx 30rpx">

        <view style="position: relative;">
          <card 
            :data="item"
            :id="taskId"
            :g_id='g_id'
            :admin_id='admin_id'
            :host=host
            :trueone=trueone
            class="color"
            style="width: 100%;"
            ref="myordernum"
            :alldata=alldata
          />
          </view>
    </view>
         <u-loadmore :status="status" :icon-type="iconType" :load-text="loadText" />


  </view>
</template>
<script>
import card from "./carddan";
export default {
  components: {
    card
  },
  data() {
    return {
    
      alldata: {},
      timer: null,
      timer1: null,
      groupNemberList: [],
      taskId: "1",
      timeone: 0,
      status: "nomore",
      iconType: "flower",
      iconType: "flower",
      loadText: {
        loadmore: "暂无数据",
        loading: "努力加载中",
        nomore: "没有更多数据"
      }
    };
  },
  watch: {
    "$store.active_devices": {
      handler(val, old) {
        // console.log('-------------')
        console.log(old);
        // this.alldata=val
      },
      deep: false,
      immediate: true
    }
  },
  onLoad(val) {
    this.g_id = val.g_id;
    this.admin_id = val.admin_id;
    this.host = val.host;
    this.trueone = val.trueone;
  },
  onShow() {
  // URL='api/'
    URL='https://iotplat.yunzhen.tech:8083/runde_api/'

    this.getList();
    uni.showLoading({
      title: "加载中"
    });
    let _this = this;
    uni.request({
      url:URL+ "index.php?ctl=group&act=get_group_member_list",
      data: {
        admin_id: _this.admin_id,
        g_id: _this.g_id
      },
      header: {
        "content-type": "application/json"
      },
      method: "POST",
      success: res => {
        // console.log(res);
        if (res.data.msg == "获取成功！") {
          _this.groupNemberList = res.data.data;
          _this.text = "request success";
          // _this.monitorList(res.data.data[0].user_id);
        } else {
          
          uni.showToast({
            title: "获取失败，请重试！",
            icon: "none",
            duration: 2000
          });
            uni.navigateTo({
      url:
        `/pages/helmet/login?search=true`
    });
        }
        // console.log(res, "lllllllllllllllllllllllllllllllllllllllllllll");
        this.groupNemberList = res.data.data;
        // this.text = "request success";
        // _this.monitorList(res.data.data[0].user_id);
        uni.hideLoading();
      },
      fail: res => {
        uni.hideLoading();
        uni.showToast({
          title: "服务器出错，请重试！",
          icon: "none",
          duration: 2000
        });
          uni.navigateTo({
      url:
        `/pages/helmet/login?search=true`
    });
      }
    });

    this.timer = setInterval(() => {
      uni.request({
        url: URL+"index.php?ctl=group&act=get_group_member_list",
        data: {
          admin_id: _this.admin_id,
          g_id: _this.g_id
        },
        header: {
          "content-type": "application/json"
        },
        method: "POST",
        success: res => {
          // console.log(res);
          if (res.data.msg == "获取成功！") {
            _this.groupNemberList = res.data.data;
            _this.text = "request success";
            // _this.monitorList(res.data.data[0].user_id);
          } else {
            uni.showToast({
              title: "获取失败，请重试！",
              icon: "none",
              duration: 2000
            });
  uni.navigateTo({
      url:
        `/pages/helmet/login?search=true`
    });
          }
          // console.log(res);
          this.groupNemberList = res.data.data;
          // this.text = "request success";
          // _this.monitorList(res.data.data[0].user_id);
          uni.hideLoading();
        },
        fail: res => {
          uni.hideLoading();
          uni.showToast({
            title: "服务器出错，请重试！",
            icon: "none",
            duration: 2000
          });
            uni.navigateTo({
      url:
        `/pages/helmet/login?search=true`
    });
        }
      });
    }, 3000);
  },
  beforeDestroy() {
    clearInterval(this.timer);
    clearInterval(this.timer1);
    this.timer1 = null;
  },
  destroyed() {
    clearInterval(this.timer);
    clearInterval(this.timer1);
    this.timer1 = null;
  },
  onBackPress(options) {
    console.log("要指定返回的页面");
    uni.navigateTo({
      url:
        `/pages/helmet/toukuizu?admin_id=` +
        this.admin_id +
        "&host=" +
        this.host +
        "&back=" +
        true
    });
    return true;
  },
  onHide() {
    clearInterval(this.timer);
    clearInterval(this.timer1);
    window.clearTimeout(this.timer);
    window.clearTimeout(this.timer1);
    this.timer = null;
    this.timer1 = null;
    // alert("页面隐藏了乐乐乐乐乐乐乐乐");
  },
  unload() {},
  onReady() {},

  beforeDestroy() {
    clearInterval(this.timer);
    clearInterval(this.timer1);
    this.timer = null;
    this.timer1 = null;
    uni.hideLoading();
  },
  destroyed() {
    clearInterval(this.timer);
    clearInterval(this.timer1);
    this.timer1 = null;
    uni.hideLoading();
  },
  onHide() {
    clearInterval(this.timer);
    clearInterval(this.timer1);
    window.clearTimeout(this.timer);
    window.clearTimeout(this.timer1);
    this.timer = null;
    this.timer1 = null;
    uni.hideLoading();
  },
  methods: {
    getList() {
      let _this = this;
      let data = { act: "ma_get_active_devices" };
      console.log("11111111111111111");
      this.$store.dispatch("WEBSOCKET_SEND", JSON.stringify(data));
      this.timer1 = setInterval(() => {
        let data = { act: "ma_get_active_devices" };
        this.$store.dispatch("WEBSOCKET_SEND", JSON.stringify(data));
        console.log("--------");
      }, 1000);
    },
   
  }
};
</script>

<style lang="scss" scoped>
.contain {
  width: 100%;
  height: 100%;
  position: relative;
  .top-content {
    height: 90upx;
    background: linear-gradient(to left, #1040be, #026dff);
  }
}
.top-content {
  height: 160upx;
  background: linear-gradient(to left, #1040be, #026dff);
}
.top {
  // z-index: 10;
  position: absolute;
  padding: 30rpx 30rpx 18rpx 30rpx;

  width: 100%;
  top: 50rpx;
  background-color: white;
  display: flex;
  border-radius: 40rpx 40rpx 0 0;

  .btn {
    position: absolute;
    right: 35rpx;
    border-radius: 16rpx;
  }
  /deep/ .u-btn--primary {
    background: linear-gradient(to left, #1040be, #026dff);
  }
  /deep/ .uni-input-placeholder {
    font-size: 22rpx;
    color: #989898 !important;
    // line-height:100upx;
  }
  /deep/ .u-mode-plain-primary {
    border: 1px solid #eee;
    box-shadow: 0 0 20rpx #eee;
    border-radius: 16rpx;
    color: #989898;
  }
  /deep/ .u-flex {
    margin-right: 80rpx;
  }
  .image {
    position: absolute;
    width: 28rpx;
    height: 34rpx;
    left: 45rpx;
  }
  /deep/ .u-size-default {
    padding: 18rpx 24rpx 18rpx 50rpx;
  }
  /deep/ .u-input--border {
    border: 1px solid #eee !important;
    box-shadow: 0 0 20rpx #eee;
    border-radius: 16rpx;
  }
  /deep/ .u-input__input {
    min-height: 55upx !important;
    color: #989898 !important;
  }
}
.contain {
  .card {
    width: 100%;
    margin-top: 84rpx;
  }
  .body {
    .text {
      position: relative;
      // margin-top: 10rpx;
      padding-top: 10rpx;
      height: 60rpx;
      line-height: 60rpx;
      text-align: center;
      font-size: 34rpx;
      .right {
        position: absolute;
        top: 6px;
        right: 30rpx;
        color: #777;
      }
    }
    .photo {
      // margin-top: 50rpx;
      padding-top: 60rpx;
      display: flex;
      height: 200rpx;

      .cont {
        flex: 1;
        .center {
          text-align: center;
        }
        .text {
          text-align: center;
          font-size: 28rpx;
          color: #111;
        }
      }
    }
  }
  .box-contet {
    width: 100%;
    overflow-y: auto;
    // margin-top: 20rpx;
    .cardlist {
      height: 100%;
      .swiper-item {
        height: 100%;
      }
    }
  }
  .list {
    width: 100%;
    padding: 30rpx;
    .color {
      // border-bottom: 15rpx solid #eee;
    }
  }
  .bottom {
    .title {
      font-size: 18px;
      font-weight: 600;
      text-align: center;
      margin-top: 10px;
    }
    .input {
      width: 100%;
      padding: 20rpx 50rpx 10rpx;
    }
    .foot {
      display: flex;
      .btn {
        flex: 1;
        margin: 60rpx 50rpx 0rpx;
      }
    }
  }
  // .fixs {
  //   position: fixed;
  //   bottom: 100rpx;
  //   right: 40rpx;
  //   width: 120rpx;
  //   height: 120rpx;
  //   background: #333;
  //   background: linear-gradient(-34deg, #1040be, #026dff);
  //   // opacity: 0.3;
  //   border-radius: 50%;
  //    display: flex;
  //    justify-content: center;
  //    align-items: center;
  // }
  .fix {
    position: fixed;
    bottom: 100rpx;
    right: 40rpx;
    z-index: 9999;
    image {
      height: 120rpx;
      width: 120rpx;
    }
  }
}
/deep/ .u-swipe-action {
  // position: relative;
}
/deep/ .u-swipe-content {
  // width:1200rpx
}
/deep/ .u-swipe-del {
  // overflow: hidden;
  // right: -20rpx;
  // position: relative;
  // width:50rpx !important;
  left: 4rpx;
  // height: 280rpx;
  margin-bottom: 20rpx;
  // top: 80rpx;
  // margin-right: 10rpx;
  border-radius: 25rpx;
}
/deep/ .u-swipe-view {
  width: 100%;
  // background-color: red;
}

/deep/ .u-mode-center-box {
  height: initial !important;
}
/deep/ .uni-scroll-view {
  height: initial !important;
  margin: 10px 4px;
}
/deep/ .content-clear-icon {
  font-size: 32rpx;
}
/deep/ .uni-easyinput__content {
  background-color: white;
}
.bottombox {
  margin-top: 15rpx;
  width: 100%;
  height: 50rpx;
  position: absolute;
  background-color: rgba(16, 91, 245, 74%);
  border-radius: 20px;
  color: white;
  width: 170rpx;
  display: flex;
  align-items: center; /*垂直居中 */
  justify-content: center;
  right: 64%;
  bottom: 8.5%;
}

.bottombox1 {
  margin-top: 15rpx;
  width: 100%;
  height: 50rpx;
  position: absolute;
  background-color: rgba(16, 91, 245, 74%);
  border-radius: 20px;
  color: white;
  width: 170rpx;
  display: flex;
  align-items: center; /*垂直居中 */
  justify-content: center;
  right: 34%;
  bottom: 8.5%;
}

.bottombox2 {
  margin-top: 15rpx;
  width: 100%;
  height: 50rpx;
  position: absolute;
  background-color: rgba(16, 91, 245, 74%);
  border-radius: 20px;
  color: white;
  width: 170rpx;
  display: flex;
  align-items: center; /*垂直居中 */
  justify-content: center;
  right: 37%;
  bottom: 14%;
}

</style>

